Skip to content

Conversation

@rkistner
Copy link
Contributor

@rkistner rkistner commented Jul 19, 2024

For websocket connections, the authentication token is provided on the connection setup (RSocket SETUP frame).

The current implementation parsed the token in the connection setup via the contextProvider, but only checked that it was valid in the RSocket stream. It would then close the RSocket stream if authentication failed, while the websocket itself stayed open.

This now adds the same validation on the connection level via the contextProvider. This causes the entire websocket to be closed when authentication fails.

We have no websocket routes using anonymous authentication, so proper per-route auth is not a consideration now.

There is probably a bug on journey-js as well. It appears to currently re-create the entire connection if a RSocket stream errors, without closing the previous connection.

Combining those two issues, in some cases the client would retry every 5 seconds, get an auth error each time, but keep the old connections open. This then quickly runs into the connection limits on the server, resulting in SERVER_BUSY errors.

@changeset-bot
Copy link

changeset-bot bot commented Jul 19, 2024

🦋 Changeset detected

Latest commit: 2a8c614

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@powersync/service-image Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rkistner rkistner merged commit 613b52e into main Jul 19, 2024
@rkistner rkistner deleted the fix-websocket-authentication-errors branch July 19, 2024 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants